package com.apes.fn.server.servicePlan.model;

import com.apes.fn.tms.model.Site;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.frame.model.Dept;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @program:
 * @description:
 * @author: lws
 * @create: 2023/3/20 11:40
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ClientInvoiceRulesItem.CONST_TABLE_NAME)
public class ClientInvoiceRulesItem extends Model {
    public static final  String CONST_TABLE_NAME = "CLIENT_INVOICE_RULES_ITEM";

    @Id
    @Column(name = "id", length = 30)
    @Comment("可服务门店编码")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "客户开票规则明细", padding = 7)
    private String id;

    @ManyToOne(optional = false)
    @JoinColumn(name = "CLIENT_INVOICE_RULES_ID", referencedColumnName = "id")
    @Comment("客户开票规则编码")
    private ClientInvoiceRules clientInvoiceRules;

    @Comment("门店")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dept_id", referencedColumnName = "id", nullable = false)
    private Dept dept;

    @Column(name = "CROSS_SINGLE_RATIO", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("跨单比率")
    private double crossSingleRatio = 0;
}
